#ifndef SHAPE_HXX
#define SHAPE_HXX

#include <opencv2/core.hpp>

#define FISH_ICON_RATIO 0.1

enum ShapeType
{
    SHAPE_RECT=0,
    SHAPE_FISH,
    SHAPE_POLYGON
};

enum ShapeFishSelectStatus
{
    SFS_NONE=0,
    SFS_HEAD,
    SFS_MASS
};

class Shape
{
public:
    Shape();

    inline void setShapeType(ShapeType type) { _shapeType = type;}
    inline ShapeType getShapeType() { return _shapeType; }

    virtual void setRect(cv::Rect2d rect) = 0;
    virtual cv::Rect2d getRect() = 0;

public:
    ShapeType _shapeType;
};

class ShapeRect:public Shape
{
public:
    ShapeRect(double x, double y, double w, double h);
    ShapeRect(cv::Rect2d rect);

    virtual cv::Rect2d getRect() { return _rect; }
    virtual void setRect(cv::Rect2d rect) { _rect = rect; }

    void setRect(double x, double y, double w, double h);
private:
    cv::Rect2d _rect;
};

class ShapeFish:public ShapeRect
{
public:
    ShapeFish(double x, double y, double w, double h, double hx, double hy, double mx, double my);
    ShapeFish(cv::Rect2d rect, cv::Point2d headCenter, cv::Point2d massCenter);
    ShapeFish(cv::Rect2d rect);

    inline cv::Point2d& getHeadCenter() { return _headCenter; }
    inline cv::Point2d& getMassCenter() { return _massCenter; }

    inline void setHeadCenter(cv::Point2d pt) { _headCenter = pt; }
    inline void setMassCenter(cv::Point2d pt) { _massCenter = pt; }

    bool isPointOnHeadIcon(cv::Point2d pt);
    bool isPointOnMassIcon(cv::Point2d pt);

    inline ShapeFishSelectStatus getSelectStatus() { return _sfsStatus; }
    inline void setSelectStatus(ShapeFishSelectStatus status) { _sfsStatus = status; }

private:
    cv::Point2d _headCenter;
    cv::Point2d _massCenter;

    ShapeFishSelectStatus _sfsStatus;
};

class ShapePolygon:public Shape
{

};

#endif // SHAPE_HXX
